<template>
    <div>
        {{$store.state.A.list}}
        <br>
        {{$store.state.B.names}}
        <h1>{{$store.state.name}}</h1>
        <button @click="$store.commit('setName','老李')">修改</button>
    </div>
</template>

<script>
export default {
    name:"Index",
    mounted(){
        console.log(this.$store)
        console.log(this.$store.state.A)
        console.log(this.$store.state.B)
        //调用父级的muataton方法
        this.$store.commit("setName",'老张')
        //调用子集的mutation方法
        this.$store.commit("A/setList",{id:2,text:'我是新增'})
        this.$store.commit("B/setNames",'柳树')
    }
}
</script>

<style>

</style>